<%--
  Created by IntelliJ IDEA.
  User: cyy
  Date: 2020/2/22
  Time: 20:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link href="/static/bootstrap/css/bootstrap.css" rel="stylesheet">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="https://unpkg.com/default-passive-events"></script>
<%-- <script type="text/javascript" src="http://api.map.baidu.com/getscript?v=2.0&ak=z6WB81KeyMnLditv8QBmBbo2xEMIKoFi&services=&t=20200103103842"></script>--%>

    <script type="text/javascript" src="http://api.map.baidu.com/getscript?v=2.0&ak=z6WB81KeyMnLditv8QBmBbo2xEMIKoFi&services=&t=20200103103842"></script>
    <style type="text/css">
        /*.allmap{
            height: 500px  !important;
            overflow:scroll  !important;
            position: absolute  !important;
        }*/
        div{
            height: 500px;
            /*position: absolute;*/
        }
    </style>

</head>
<body>
<div >
    <span>地图:</span>
    <div id="allmap" class="allmap">
    </div>
</div>
</body>
<script type="text/javascript">

    function handler(event) {
        console.log(event.type); // log event type
    }
    document.addEventListener("mousewheel", handler, {passive:true});

    // 百度地图API功能
    var map = new BMap.Map("allmap");
    map.centerAndZoom(new BMap.Point(114.27282,30.45875),11);  //启用滚轮放大缩小，默认禁用
    /*var content = '<div style="margin:0;line-height:20px;padding:2px;">' +
                   '<img src="img/logo.png" alt="" style="float:right;zoom:1;overflow:hidden;width:100px;height:100px;margin-left:3px;"/>' +
                   '地址：北京市海淀区上地十街10号<br/>电话：(010)59928888<br/>简介：百度大厦位于北京市海淀区西二旗地铁站附近，为百度公司综合研发及办公总部。' +
                 '</div>';

   //创建检索信息窗口对象
   var searchInfoWindow = null;
   searchInfoWindow = new BMapLib.SearchInfoWindow(map, content, {
           title  : "百度大厦",      //标题
           width  : 290,             //宽度
           height : 105,              //高度
           panel  : "panel",         //检索结果面板
           enableAutoPan : true,     //自动平移
           searchTypes   :[
               BMAPLIB_TAB_SEARCH,   //周边检索
               BMAPLIB_TAB_TO_HERE,  //到这里去
               BMAPLIB_TAB_FROM_HERE //从这里出发
           ]
       });*/
    map.enableScrollWheelZoom(true);                                          //启用地图惯性拖拽，默认禁用


    //比例尺、工具条
    var top_left_control = new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT});// 左上角，添加比例尺
    var top_left_navigation = new BMap.NavigationControl();  //左上角，添加默认缩放平移控件
    var top_right_navigation = new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL});

    map.addControl(top_left_control);
    map.addControl(top_left_navigation);
    map.addControl(top_right_navigation);


    // 用经纬度设置地图中心点
    function theLocation(){
        if(document.getElementById("longitude").value != "" && document.getElementById("latitude").value != ""){
            map.clearOverlays();
            var new_point = new BMap.Point(document.getElementById("longitude").value,document.getElementById("latitude").value);
            var marker = new BMap.Marker(new_point);  // 创建标注
            map.addOverlay(marker);              // 将标注添加到地图中
            map.panTo(new_point);
            marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
        }
    }

</script>
</html>
